version 8.2
capture clear
capture log close
set more off
set mem 1000m
set mat 800



use "Doing business_Full data.dta"
ren economy countryname
***rename the countries!
*sort countryname
*keep if countryname!=countryname[_n-1]
*browse countryname

replace countryname="Congo, Dem. Rep." if countryname=="Congo, Dem Rep"
replace countryname="Congo, Rep." if countryname=="Congo, Rep"
replace countryname="Egypt, Arab Rep." if countryname=="Egypt, Arab Rep"
replace countryname="Iran, Islamic Rep." if countryname=="Iran, Islamic Rep"
replace countryname="Micronesia, Fed. Sts." if countryname=="Micronesia, Fed Sts"
replace countryname="Puerto Rico" if countryname=="Puerto Rico US"
replace countryname="St. Kitts and Nevis" if countryname=="St Kitts and Nevis"
replace countryname="St. Lucia" if countryname=="St Lucia"
replace countryname="St. Vincent and the Grenadines" if countryname=="St Vincent and the Grenadines"
replace countryname="Yemen, Rep." if countryname=="Yemen, Rep"

gen year2=substr(year,3,.)
destring year2, replace
drop year
ren year2 year 

egen dtf=rowmean(startingabusinessdtf dealingwithconstructionpermitsdt gettingelectricitydtf registeringpropertydtf gettingcreditdtf protectingminorityinvestorsdtf payingtaxesdtf tradingacrossbordersdtf resolvinginsolvencydtf)
*everything except enforcingcontractsdtf

keep countryname year dtf
sort countryname year
save "Doing business_Full data_clean.dta", replace

exit
